<template>
  <div class="search">
    <label class="projectName">
      <span>项目名称</span>
      <el-input
        type="text"
        placeholder="请输入"
        v-model="$store.state.danger.safeSearchDTO.projectName"
        clearable
      ></el-input>
    </label>
    <label class="datePicker">
      <span>上传时间</span>
      <el-date-picker
        v-model="$store.state.danger.date"
        type="daterange"
        align="right"
        unlink-panels
        range-separator="至"
        start-placeholder="开始时间"
        end-placeholder="结束时间"
        :picker-options="pickerOptions"
        value-format="yyyy-MM-dd HH:mm:ss"
      ></el-date-picker>
    </label>
    <label class="btns">
      <button class="searchBtn" @click="getDangerList">查询</button>
      <button class="resetBtn" @click="reset">重置</button>
    </label>
  </div>
</template>
<script>
import { pickerOptions } from '../../../settings.js'
export default {
  data () {
    return {
      pickerOptions
    }
  },
  created () {
    this.$store.dispatch('danger/reset')
    this.getDangerList()
  },
  methods: {
    // 获取隐患列表
    getDangerList () {
      this.$store.dispatch('danger/getList')
    },
    // 重置查询条件
    async reset () {
      await this.$store.dispatch('danger/reset')
      await this.$store.dispatch('danger/getList')
    }
  }
}
</script>
<style scoped lang="scss">
::v-deep .el-range-separator {
  width: 10%;
}
.search {
  width: 100%;
  background-color: #fff;
  border-radius: 5px;
  padding: 24px 0 0 30px;
  font-size: 14px;
  color: #666666;
  margin-bottom: 24px;

  label {
    display: inline-block;
    margin-bottom: 20px;
    margin-right: 60px;
    vertical-align: middle;

    .el-input {
      padding-left: 12px;
    }
  }
  .projectName {
    .el-input {
      width: 252px;
    }
  }
  .datePicker {
    margin-right: 30px;
    .el-date-editor {
      margin-left: 12px;
    }
  }

  .btns {
    button {
      width: 84px;
      height: 36px;
      border-radius: 18px;
      border: none;
      cursor: pointer;
    }
    .searchBtn {
      background-color: #4868ff;
      color: #fff;
      margin-right: 16px;
    }
    .resetBtn {
      border: 1px solid #4868ff;
      background-color: transparent;
      color: #4868ff;
    }
  }
}
</style>
